// Copyright(C) 2002-2003 Hugo Rumayor Montemayor, All rights reserved.
using System;
using System.Text;

namespace ID3Lib
{
	/// <summary>
	/// Summary description for BaseFrame.
	/// </summary>
	public abstract class FrameBase
	{
		#region Fields
		private string _frameDescription = null;
		private string _tag = null;
		private ushort _flags = 0;
		#endregion

		#region Constructor
		internal FrameBase(string tag)
		{
			tag.Trim();
			if(tag.Length != 4)
			{
				throw new InvalidFrameException("Invalid frame type: '" + tag +"', it must be 4 characters long.");
			}
			_tag = tag;
		}
		#endregion

		#region  Properties
		/// <summary>
		/// Tag frame flags
		/// </summary>
		public ushort Flags
		{
			get{return _flags;}
			set{_flags = value;}
		}
		/// <summary>
		/// Description of the ID3 tag frame
		/// </summary>
		public string FrameDescription
		{
			get{ return _frameDescription; }
		}
			
		/// <summary>
		/// ID3 Tag frame type
		/// </summary>
		public string Tag
		{
			get{return _tag;}
		}
		#endregion

		#region Methods
		/// <summary>
		/// ID3 frame tag description
		/// </summary>
		/// <param name="description">The tag frame description</param>
		internal void SetDescription(string description)
		{
			_frameDescription = description;
		}

		/// <summary>
		/// Load frame form binary data
		/// </summary>
		/// <param name="frame">binary tag frame representation</param>
		public abstract void Parse(byte[] frame);
		/// <summary>
		/// Save frame to binary data
		/// </summary>
		/// <returns>binary tag frame representation</returns>
		public abstract byte[] Make();
		#endregion
	}
}
